Add Hardlink Compatibility with Separate Rebalance Script #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a script which supports rebalancing hardlinked files that are in two separate directories. The two directories are passed as inputs and are treated as source and destination directories. The hardlinks in the "dest" directory are first removed while retaining the file path name. Rebalancing is performed as usual on files in the source directory, then the hardlink is recreated in the destination. The effect is to preserve the original hardlink structure (for inodes that have exactly two links) while only needing to rebalance one of the two hardlinks. This script has only been tested on linux but should also work on macos and freebsd with very little work.
Note that this also removes the option to skip hardlinks in the original "zfs-inplace-rebalance.sh" script and instead makes that the default behavior. No hardlinked files will be processed in that script. It is possible that the scripts could be merged, but for simplicity I've kept them separate for now since "zfs-hardlink-rebalance.sh" requires two directory inputs while "zfs-inplace-rebalance.sh" only requires one.